<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Island Auctions</title>
</head>

<body>
<table width="100%" height="100%" border="2">
  <tr>
    <td width="22%" height="95"><img src="logo.png" width="163" height="154" alt="Logo" /></td>
    <td width="78%"><h1>Island Auctions</h1>
    <p> Turning Junk Into Money</p></td>
  </tr>
  <tr>
    <td valign="top"><p><a href="index.jsp">Home</a></p>
    <p><a href="Browse.jsp">Browse</a></p>
    <p><a href="index.jsp">Search</a></p>
    <p><a href="profile.jsp">Profile</a></p>
    <p><a href="Users.jsp">Users</a></p>
    <%
    try{
	    if(session.getValue("login") != null)
	    {%>
	    	<p><a href="Logout.jsp">Logout</a></p>
	    <%}
	    else
	    {%>
	    	<p><a href="login.jsp">Login</a></p>
	    <%}
    }catch(java.lang.IllegalStateException e)
    {%>
		<p><a href="login.jsp">Login</a></p><%
}%>

<%
try{
int eLevel = -1;
Object o = session.getValue("empLevel");
if(o != null)
{
	eLevel = (java.lang.Integer)o;
}


    if(eLevel == 1)
    {%>
    	<p><a href="ManageEmployees.jsp">(Manage Employees)</a></p></td>
    <%}
    else
    {%>
    <br>
    <%}
}catch(java.lang.IllegalStateException e)
{%>
<br>
<%}
    %>
    <td valign="top">
    		<p><a href="Help.jsp">Help</a></p>
        <%
    try{
    	int empLevel = -1;// (java.lang.Integer)session.getValue("empLevel");
    	if(session.getValue("empLevel") != null)
    		empLevel = (java.lang.Integer)session.getValue("empLevel");
	    if(session.getValue("login") != null && empLevel < 0)
	    {

%>
				<p><a href="NewAuction.jsp">NewAuction</a></p>
<%
		    	int custID = (Integer)session.getValue("customerID");
		    	String Id = (String)session.getValue("login");
		    	String mysJDBCDriver = "com.mysql.jdbc.Driver"; 
		    	String mysURL = "jdbc:mysql://mysql2.cs.stonybrook.edu:3306/jedale"; 
		    	String mysUserID = "jedale"; 
		    	String mysPassword = "107200855";
		    	Class.forName(mysJDBCDriver).newInstance();
		    	java.util.Properties sysprops=System.getProperties();
		    	sysprops.put("user",mysUserID);
		    	sysprops.put("password",mysPassword);
	
		    	//connect to the database
		    	java.sql.Connection conn=null;
	   			conn=java.sql.DriverManager.getConnection(mysURL,sysprops);
	   			System.out.println("Connected successfully to database using JConnect");
	
	   			java.sql.Statement stmt1=conn.createStatement();
	   			
	   			ResultSet rs = stmt1.executeQuery("SELECT I.ItemID, I.Name, I.ItemDescription, A.AuctionID " +
	   					"FROM Item I, Auction A " +
	   					"WHERE I.ItemID = A.AuctionID AND I.ItemType IN (SELECT B.ItemType FROM Bought B WHERE B.CustomerID =" +custID + ")  AND " +
	   					"I.ItemID NOT IN (Select B.ItemID FROM Bought B WHERE B.CustomerID =" +custID+ ")");
	   			
				%><h2>Recomendations for <%=Id %></h2>
				<table border="8" id="TABLE1" onclick="return TABLE1_onclick()">
					<tr>
						<td style="width: 84px"><span style="font-size: 10pt">
								Item Name</span></td>
						<td style="width: 150px"><span style="font-size: 10pt">Description</span></td>
					</tr>
					<%  
					while(rs.next())
					{
					%>
									<tr>
										<td style="width: 84px"><span style="font-size: 10pt"><a href="AuctionPage.jsp?AuctionID=<%=rs.getString(4)%>"><%=rs.getString(2)%></a></span></td>
										<td style="width: 187px"><span style="font-size: 10pt"><%=rs.getString(2)%></span></td>
									</tr>
									<%      		
					}
	    }
	    else if(empLevel >= 1)
	    {

	    }
	    else
	    {%>
	    	<p><a href="login.jsp">Welcome Click Here To Login</a></p>
	    <%}
	    
    }catch(java.lang.IllegalStateException e)
    {%>
		<p><a href="login.jsp">Welcome Click Here To Login</a></p>
		<%
}catch(Exception e)
{
		e.printStackTrace();
}%>
</td>
  </tr>
</table>
</body>
</html>